Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
decompress-response
Advanced tools
The decompress-response npm package is used to decompress HTTP responses that are compressed. This is useful when making HTTP requests and the server responds with compressed data, such as gzip or deflate. The package automatically detects the encoding and decompresses the response so that it can be easily processed in its uncompressed form.
Decompressing HTTP responses
This code sample demonstrates how to use decompress-response to decompress an HTTP response. The 'http.get' method is used to make a GET request to a server. The response is then passed through the decompressResponse function, which returns a stream with the decompressed response. Finally, the decompressed data is piped to the standard output.
const http = require('http');
const decompressResponse = require('decompress-response');
http.get('http://example.com', (res) => {
res = decompressResponse(res);
res.pipe(process.stdout);
});
The pump package is a small node module that pipes streams together and destroys all of them if one of them closes. While it does not provide decompression functionality by itself, it can be used in conjunction with stream-compression modules to handle errors and clean up streams properly after decompression.
Got is a human-friendly and powerful HTTP request library for Node.js. Got supports decompression of HTTP responses out of the box, similar to decompress-response, but it also provides a much richer set of features for making HTTP requests, such as retries, pagination, and more.
node-fetch is a light-weight module that brings the Fetch API to Node.js. It allows you to make HTTP requests similar to the way you would in a browser. The Fetch API supports transparent decompression of responses, which is a feature also provided by decompress-response, but node-fetch offers a broader feature set for making requests and handling responses.
Axios is a promise-based HTTP client for the browser and Node.js. It supports response data decompression, much like decompress-response. However, axios provides a wide range of features such as interceptors, automatic transforms for JSON data, and client-side protection against XSRF.
Decompress a HTTP response if needed
Decompresses the response from http.request
if it's gzipped, deflated or compressed with Brotli, otherwise just passes it through.
Used by got
.
$ npm install decompress-response
const http = require('http');
const decompressResponse = require('decompress-response');
http.get('https://sindresorhus.com', response => {
response = decompressResponse(response);
});
Returns the decompressed HTTP response stream.
Type: http.IncomingMessage
The HTTP incoming stream with compressed data.
FAQs
Decompress a HTTP response if needed
The npm package decompress-response receives a total of 14,842,297 weekly downloads. As such, decompress-response popularity was classified as popular.
We found that decompress-response demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.